package org.alex.samples.dao;

import java.util.ArrayList;
import java.util.List;

import org.alex.samples.model.ExamTest;
import org.springframework.stereotype.Repository;

@Repository
public class ExamTestDAOImpl extends BaseHibernateDao<ExamTest> implements IExamTestDAO {

	@Override
	public List<ExamTest> getTestListBySubAndTestType(Integer subId, Integer testTypeId) {
		return this.find("from ExamTest et where et.subId = " + subId + " and et.examTestType.id = " + testTypeId);
	}

	@Override
	public List<ExamTest> getTestListByIdList(List<Integer> randomTestIdList) {
		List<ExamTest> examTests = new ArrayList<ExamTest>();
		ExamTest examTest = null;
		for(Integer integer : randomTestIdList) {
			examTest = this.get(integer);
			if(examTest != null) {
				examTests.add(examTest);
			}
		}
		return examTests;
	}

	@Override
	public List<ExamTest> getAllExamTestBySubId(Integer subId) {
		String hql = "from ExamTest et where et.subId = " + subId;
		return this.find(hql);
	}

}
